/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.myapp.struts.User.EditProfile;

import com.myapp.model.usuarios.Usuarios;
import com.myapp.struts.User.NewUser.NewUserForm;
import com.myapp.svc.User.UserSvc;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/**
 *
 * @author Jaime
 */
public class EditProfileAction extends org.apache.struts.action.Action {

    /*
     * forward name="success" path=""
     */
    private static final String SUCCESS = "success";

    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        Usuarios usr = new Usuarios();
        UserSvc usrSvc = new UserSvc();
        HttpSession session = request.getSession();
        usr = (Usuarios) session.getAttribute("usuario");
        
        ((EditProfileForm) form).setIdUser(usr.getIdusuario());
        ((EditProfileForm) form).setLogin(usr.getAlias());
        ((EditProfileForm) form).setPassword(usr.getPassword());
        ((EditProfileForm) form).setName(usr.getNombre());
        ((EditProfileForm) form).setSurname(usr.getApellidos());
        ((EditProfileForm) form).setEmail(usr.getEmail());
        ((EditProfileForm) form).setLocation(usr.getUbicacion());
        //((EditProfileForm) form).setAvailability(usr.getDispcorregir());
        //((NewUserForm) form).setAvatar(usr.getAvatar());

        return mapping.findForward(SUCCESS);
    }
}
